<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/context/mytags.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <title>sql结果预览</title>
    <t:base type="jquery,easyui,tools,DatePicker"></t:base>
    <script type="text/javascript" src="webpage/com/zybk/cbscgreporthead/export.js"></script>
    <script type="text/javascript">

        // /*导出报告*/
        function exportReport() {
            exportEXCEL($("#tableName").val()+"_"+$("#tableDate").val(), $("#cgReportCount"))
        }

        /**
         * 加载解析查询内容
         */
        $(function () {
            var jsonC = '';
            var jsonsql = ${jsonSql};
            $.each(jsonsql, function (idx, item) {
                if(item.isgroup == "1"){
                    jsonC += item.field_chinese + ' ';
                    //生成sql
                    $.ajax({
                        url: "cbsConditionController.do?getCritByid",
                        data: {
                            "id": item.querycriteria
                        },
                        async: false,
                        type: 'POST',
                        success: function (data) {
                            var d = $.parseJSON(data);
                            if (d.success) {
                                var o = d.obj;
                                jsonC += o;
                            }
                        }
                    });
                    jsonC += ' ' + item.content + '\n';
                }
            });
            $("#jsonSql").html(jsonC);
        });

    </script>
</head>
<body>
<div style="margin: 20px">
    <input type="hidden" id="tableName" value="${name}"> <%--报表名称--%>
    <input type="hidden" id="tableDate" value="${date}"> <%--执行时间--%>
    <hr>
    <div>
        <br><span>结果件数:${sqlResultlistSize}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>执行时间:${date}</span>
    </div>
    <br>
    <div>
        <label>查询内容：</label>
        <textarea style='vertical-align:middle;border: 1px solid #94BBE2;width:80%;word-break:break-all;'
                  rows=4 id="jsonSql" disabled></textarea>
    </div>
    <div style="text-align:right; padding-right:10px;">
        <a id="dlink" style="display:none;"></a>
        <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-putout',plain:'true'"
           onclick="exportReport()">导出报告</a>
    </div>
    <br>
    <div>
        <table class="report_table" style="width: 100%;" cellpadding="0" cellspacing="1" class="formtable"
               id="cgReportCount">
            <thead>
            <tr>
                <c:forEach items="${sqlResultName}" var="r">
                    <th nowrap="nowrap">${r}</th>
                </c:forEach>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${sqlResultlist}" var="s">
                <tr class="a1">
                    <c:forEach items="${s}" var="r">
                        <td nowrap="nowrap">${r.value}</td>
                    </c:forEach>
                </tr>
            </c:forEach>
            </tbody>
        </table>
    </div>
</div>
</body>
</html>
